package com.lz.wsy.controller;

import com.lz.utils.Result;
import com.lz.wsy.pojo.Notice;
import com.lz.wsy.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    /** 查询所有数据 */
    @GetMapping("/list")
    public Result list(){
        return Result.success(noticeService.list());
    }

    /** 通过主键查询单条公告 */
    @GetMapping("/get/{noticeId}")
    public Result get(@PathVariable("noticeId") Integer noticeId){
        return Result.success(noticeService.get(noticeId));
    }

    /** 新增或者编辑公告 */
    @PostMapping("/saveAndEdit")
    public Result saveAndEdit(@RequestBody Notice notice){
        return Result.success(noticeService.addAndEdit(notice));
    }

}













